package live_schedule

import (
	"vrcm/src/vrcm/common/models"
)

type SourceBasic struct {
	models.Model

	TenantId           string         `json:"tenant_id" gorm:"type:varchar(50);comment:租户id"`
	SourceName         string         `json:"source_name" gorm:"type:varchar(50);comment:信源名称"`
	EquipNo            string         `json:"equip_no" gorm:"type:varchar(50);comment:设备号"`
	EquipType          int            `json:"equip_type" gorm:"type:tinyint;comment:设备类型 1 studiolink 2聚合传输设备"`
	SourceType         int            `json:"source_type" gorm:"type:tinyint;comment:信源类型 1.标准流 2播总控 3传输平台"`
	Area               int            `json:"area" gorm:"type:tinyint;comment:区域1.公网 2内网"`
	ProtocolType       int            `json:"protocol_type" gorm:"type:tinyint;comment:协议类型1rtmp 2hls 3https 4srt 5udp 6sdi"`
	StreamType         int            `json:"stream_type" gorm:"type:tinyint;comment:流类型 1.推流 2拉流 3"`
	SourceState        int            `json:"source_state" gorm:"type:tinyint;comment:信源状态 1启用 2停用3 异常"`
	TaskId             string         `json:"task_id" gorm:"type:varchar(100);comment:任务id"`
	TransTaskId        string         `json:"trans_task_id" gorm:"type:varchar(100);comment:转码任务id"`
	OriginSwitchTaskId string         `json:"origin_switch_task_id" gorm:"type:varchar(100);comment:原始切换任务id"`
	TransSwitchTaskId  string         `json:"trans_switch_task_id" gorm:"type:varchar(100);comment:转码切换任务id"`
	RecordTaskId       string         `json:"record_task_id" gorm:"type:varchar(100);comment:录制任务id"`
	Delay              int            `json:"delay" gorm:"type:int;comment:延迟"`
	ActiveItem         int            `json:"active_item" gorm:"type:tinyint;comment:当前使用线路 1主 2备 3辅 4垫"`
	OutUdpUrl          string         `json:"out_udp_url" gorm:"type:varchar(300);comment:输出源udp地址"`
	TransOutUdpUrl     string         `json:"trans_out_udp_url" gorm:"type:varchar(300);comment:转码输出源udp地址"`
	IsDelete           int            `json:"is_delete" gorm:"type:tinyint;comment:是否删除 1删除 2未删除"`
	AuditState         int            `json:"audit_state" gorm:"type:tinyint;comment:1通过 2不通过 3审核中"`
	StartTime          int64          `json:"start_time" gorm:"type:int;comment:上一次起用时间"`
	StopTime           int64          `json:"stop_time" gorm:"type:int;comment:上一次停用时间"`
	SwitchType         int            `json:"switch_type" gorm:"type:tinyint;comment:1无缝 2有缝"`
	IsCustom           int            `json:"is_custom" gorm:"type:tinyint;comment:1自定义 2非自定义"`
	Kind               int            `json:"kind" gorm:"type:tinyint;comment:1原始信源 2自定义信源 3自定义设备"`
	EnableAutoSwitch   int            `json:"enable_auto_switch" gorm:"type:tinyint;comment:1启动 2关闭"`
	EquipState         int            `json:"equip_state" gorm:"type:tinyint;comment:设备状态 1启用 2停用"`
	EquipTime          int64          `json:"equip_time" gorm:"type:int;comment:设备修改时间"`
	IsShow             int64          `json:"is_show" gorm:"type:tinyint;comment:"`
	PrivateNetworkId   int64          `json:"private_network_id" gorm:"type:bigint;comment:专网id"`
	IsAAn              int            `json:"is_aan" gorm:"column:is_aan;type:tinyint;comment:全球加速 1开启 2关闭"`
	SourceContent      int            `json:"source_content" gorm:"type:tinyint;comment:信源内容 1sdi矩阵 2SMPTE2110 3NDI"`
	MatrixId           int            `json:"matrix_id" gorm:"type:bigint;comment:矩阵id"`
	SdiPort            int            `json:"sdi_port" gorm:"type:bigint;comment:矩阵端口号"`
	VideoAudio         string         `json:"video_audio" gorm:"type:varchar(30);comment:音频视频"`
	VideoSdp           string         `json:"video_sdp" gorm:"type:varchar(100);comment:VideoSdp地址"`
	AudioSdp           string         `json:"audio_sdp" gorm:"type:varchar(100);comment:AudioSdp地址"`
	AncillarySDP       string         `json:"ancillary_sdp" gorm:"type:varchar(1000);comment:AncillarySDP地址"`
	NDIStream          string         `json:"ndi_stream" gorm:"type:varchar(100);comment:NDI流"`
	ActiveCode         string         `json:"active_code" gorm:"type:varchar(100);comment:激活码"`
	Manufacturer       int            `json:"manufacturer" gorm:"type:bigint;comment:厂家"`
	Details            []SourceDetail `json:"details" gorm:"-"`
	PullUrls           []string       `json:"pull_urls" gorm:"-"`
	models.ModelTime
	models.ControlBy
}

type SourceBasicNew struct {
	models.Model

	TenantId         string `json:"tenant_id" gorm:"type:varchar(50);comment:租户id"`
	SourceName       string `json:"source_name" gorm:"type:varchar(50);comment:信源名称"`
	EquipNo          string `json:"equip_no" gorm:"type:varchar(50);comment:设备号"`
	SourceType       int    `json:"source_type" gorm:"type:tinyint;comment:信源类型 1.网络流 2线下设备"`
	Area             int    `json:"area" gorm:"type:tinyint;comment:区域1.公网 2内网"`
	ProtocolType     int    `json:"protocol_type" gorm:"type:tinyint;comment:协议类型1rtmp 2hls 3https 4srt 5udp 6sdi"`
	StreamType       int    `json:"stream_type" gorm:"type:tinyint;comment:流类型 1.推流 2拉流 3"`
	SourceState      int    `json:"source_state" gorm:"type:tinyint;comment:信源状态 1启用 2停用3 异常"`
	TaskId           string `json:"task_id" gorm:"type:varchar(100);comment:任务id"`
	OutUdpUrl        string `json:"out_udp_url" gorm:"type:varchar(300);comment:输出源udp地址"`
	IsDelete         int    `json:"is_delete" gorm:"type:tinyint;comment:是否删除 1删除 2未删除"`
	StartTime        int64  `json:"start_time" gorm:"type:int;comment:上一次起用时间"`
	StopTime         int64  `json:"stop_time" gorm:"type:int;comment:上一次停用时间"`
	PrivateNetworkId int64  `json:"private_network_id" gorm:"type:bigint;comment:专网id"`
	IsAAn            int    `json:"is_aan" gorm:"type:tinyint;comment:全球加速 1开启 2关闭"`
	SourceContent    int    `json:"source_content" gorm:"type:tinyint;comment:信源内容 1sdi矩阵 2SMPTE2110 3NDI"`
	MatrixId         int    `json:"matrix_id" gorm:"type:bigint;comment:矩阵id"`
	SdiPort          int    `json:"sdi_port" gorm:"type:bigint;comment:矩阵端口号"`
	VideoAudio       string `json:"video_audio" gorm:"type:varchar(30);comment:音频视频"`
	VideoSdp         string `json:"video_sdp" gorm:"type:varchar(100);comment:VideoSdp地址"`
	AudioSdp         string `json:"audio_sdp" gorm:"type:varchar(100);comment:AudioSdp地址"`
	AncillarySDP     string `json:"ancillary_sdp" gorm:"type:varchar(1000);comment:AncillarySDP地址"`
	NDIStream        string `json:"ndi_stream" gorm:"type:varchar(100);comment:NDI流"`
	SourceUrl        string `json:"source_url" gorm:"type:varchar(300);comment:信源地址"`
	models.ModelTime
	models.ControlBy
}

func (SourceBasicNew) TableName() string {
	return "source_basic_new"
}

type SourceDetail struct {
	models.Model

	TenantId             string `json:"tenant_id" gorm:"type:varchar(50);comment:租户id"`
	SourceId             int    `json:"source_id" gorm:"type:bigint unsigned;comment:信源id"`
	TaskId               string `json:"task_id" gorm:"type:varchar(100);comment:任务id"`
	LiveId               string `json:"live_id" gorm:"type:varchar(100);comment:全球直播id"`
	NodeId               string `json:"node_id" gorm:"type:varchar(100);comment:节点id"`
	SwitchNodeId         string `json:"switch_node_id" gorm:"type:varchar(100);comment:切换节点id"`
	SourceUrl            string `json:"source_url" gorm:"type:varchar(300);comment:信源线路"`
	UrlType              int    `json:"url_type" gorm:"type:tinyint;comment:信源地址类型 1主 2备 3辅 4垫图 5主转码 6 备转码 7辅转码"`
	IsEnable             int    `json:"is_enable" gorm:"type:tinyint;comment:1启用2禁用"`
	PushUrl              string `json:"push_url" gorm:"type:varchar(300);comment:全球直播的推流地址"`
	SrtUrl               string `json:"srt_url" gorm:"-"`
	PullUrl              string `json:"pull_url" gorm:"type:varchar(300);comment:全球直播的拉流地址"`
	InUdpUrl             string `json:"in_udp_url" gorm:"type:varchar(300);comment:输入源udp地址"`
	OutUdpUrl            string `json:"out_udp_url" gorm:"type:varchar(300);comment:输出源udp地址"`
	NodeState            int    `json:"node_state" gorm:"type:tinyint;comment:节点状态 1正常 2异常 3未配置"`
	AdditionalPublishUrl string `json:"additional_publish_url" gorm:"type:varchar(300);comment:额外的hls拉流地址"`
	StateUpdateTime      int64  `json:"state_update_time" gorm:"column:state_update_time;type:int;comment:节点状态更新时间"`
	Area                 int    `json:"area" gorm:"type:tinyint;comment:节点状态 1外网 2内网"`
	models.ModelTime
	models.ControlBy
}

type SourceDetailModel struct {
	SourceDetail  SourceDetail `json:"source_detail"`
	InSourceState int          `json:"in_source_state" comment:"输入信源状态 1未配置 2配置未输出 3配置输出且正常 4配置输出且异常"`
}

func (SourceBasic) TableName() string {
	return "source_basic"
}

func (e *SourceBasic) Generate() models.ActiveRecord {
	o := *e
	return &o
}

func (e *SourceBasic) GetId() interface{} {
	return e.Id
}

type ShareSourceConfig struct {
	models.Model

	TenantId  string `json:"tenant_id" gorm:"type:varchar(50);comment:租户"`
	SourceId  int    `json:"source_id" gorm:"type:bigint unsigned;comment:信源id"`
	IsEnable  int    `json:"is_enable" gorm:"type:tinyint;comment:是否开启 1开启 2未开启"`
	ShareType int    `json:"share_type" gorm:"type:tinyint;comment:分享类型 1公开 2部分公开"`
	models.ModelTime
	models.ControlBy
}

func (ShareSourceConfig) TableName() string {
	return "share_source_config"
}

type SourceShare struct {
	models.Model

	SourceId     int    `json:"source_id" gorm:"type:bigint unsigned;comment:信源id"`
	ShareAccount string `json:"share_account" gorm:"type:varchar(50);comment:分享人"`
	Account      string `json:"account" gorm:"type:varchar(50);comment:分享账户"`
	Remark       string `json:"remark" gorm:"type:varchar(500);comment:备注"`
	models.ModelTime
	models.ControlBy
}

func (SourceShare) TableName() string {
	return "source_share"
}

type SourceTemplate struct {
	models.Model

	TenantId                     string `json:"tenant_id" gorm:"type:varchar(50);comment:租户"`
	SourceId                     int    `json:"source_id" gorm:"type:bigint unsigned;comment:信源id"`
	TemplateId                   string `json:"template_id" gorm:"type:varchar(50);comment:模版id"`
	TaskName                     string `json:"task_name" gorm:"type:varchar(50);comment:转码任务名"`
	TransCodeTaskId              string `json:"trans_code_task_id" gorm:"type:varchar(50);comment:转码任务id"`
	TransCodeSwitchTaskId        string `json:"trans_code_switch_task_id" gorm:"type:varchar(50);comment:转码切换任务id"`
	TransCodeSwitchOutputAddress string `json:"trans_code_switch_output_address" gorm:"type:varchar(50);comment:转码切任输出地址"`
	TransCodeOutputAddress       string `json:"trans_code_output_address" gorm:"type:varchar(50);comment:转码输出地址"`
	IsEnable                     int    `json:"is_enable" gorm:"type:tinyint;comment:1启用2禁用3异常"`
	ActiveItem                   int    `json:"active_item" gorm:"type:tinyint;comment:1主2备3辅"`
	EnableAdvance                int    `json:"enable_advance" gorm:"type:tinyint;comment:高级配置1启用2禁用"`
	ServiceId                    string `json:"service_id" gorm:"type:varchar(50);comment:"`
	ServiceName                  string `json:"service_name" gorm:"type:varchar(50);comment:"`
	VideoPid                     string `json:"video_pid" gorm:"type:varchar(50);comment:"`
	AudioPid                     string `json:"audio_pid" gorm:"type:varchar(50);comment:"`
	PcrPid                       string `json:"pcr_pid" gorm:"type:varchar(50);comment:"`
	PmtPid                       string `json:"pmt_pid" gorm:"type:varchar(50);comment:"`
	ServiceProvider              string `json:"service_provider" gorm:"type:varchar(50);comment:"`
	SchedulerMode                string `json:"scheduler_mode" gorm:"type:varchar(50);comment:"`
	ServiceLoadId                string `json:"service_load_id" gorm:"type:varchar(50);comment:"`
	models.ModelTime
	models.ControlBy
}
type SourceTemplateModel struct {
	SourceTemplate SourceTemplate       `json:"source_template"`
	TransCodeTasks []TransCodeTaskModel `json:"trans_code_tasks"`
	//InSourceState  int                  `json:"in_source_state" comment:"输入信源状态 1未配置 2配置未输出 3配置输出且正常 4配置输出且异常"`
	TransState int `json:"trans_state" comment:"转码状态 1正常 2异常 3停用"`
}

func (SourceTemplate) TableName() string {
	return "source_template"
}

type TransCodeTask struct {
	models.Model

	TenantId        string `json:"tenant_id" gorm:"type:varchar(50);comment:租户"`
	SourceId        int    `json:"source_id" gorm:"type:bigint unsigned;comment:信源id"`
	TemplateId      string `json:"template_id" gorm:"type:varchar(50);comment:模版id"`
	TaskRecordId    int    `json:"task_record_id" gorm:"type:bigint;comment:任务记录id"`
	TaskId          string `json:"task_id" gorm:"type:varchar(100);comment:任务id"`
	SwitchNodeId    string `json:"switch_node_id" gorm:"type:varchar(100);comment:切换任务id"`
	TaskName        string `json:"task_name" gorm:"type:varchar(50);comment:任务名"`
	IsCustom        int    `json:"is_custom" gorm:"type:tinyint;comment:是否自定义 1是 2否"`
	CustomUrl       string `json:"custom_url" gorm:"type:varchar(100);comment:自定义地址"`
	NodeId          string `json:"node_id" gorm:"type:varchar(100);comment:节点id"`
	SourceUrl       string `json:"source_url" gorm:"type:varchar(300);comment:信源线路"`
	UrlType         int    `json:"url_type" gorm:"type:tinyint;comment:信源地址类型 1主 2备 3辅 4垫图"`
	NodeState       int    `json:"node_state" gorm:"type:tinyint;comment:节点状态 1正常 2异常"`
	InUdpUrl        string `json:"in_udp_url" gorm:"type:varchar(300);comment:输入源udp地址"`
	OutUdpUrl       string `json:"out_udp_url" gorm:"type:varchar(300);comment:输出源udp地址"`
	MonitorId       string `json:"monitor_id" gorm:"type:varchar(50);comment:监控id"`
	IsEnable        int    `json:"is_enable" gorm:"type:tinyint;comment:1启用2禁用"`
	StateUpdateTime int64  `json:"state_update_time" gorm:"column:state_update_time;type:int;comment:节点状态更新时间"`
	models.ModelTime
	models.ControlBy
}

type TransCodeTaskModel struct {
	TransCodeTask TransCodeTask `json:"source_detail" comment:"转码信源详情"`
	InSourceState int           `json:"in_source_state" comment:"输入信源状态 1未配置 2配置未输出 3配置输出且正常 4配置输出且异常"`
}

func (TransCodeTask) TableName() string {
	return "trans_code_task"
}

type SourceRecordTask struct {
	models.Model

	SourceId         int    `json:"source_id" gorm:"type:bigint unsigned;comment:信源id"`
	TenantId         string `json:"tenant_id" gorm:"type:varchar(50);comment:租户"`
	ChannelId        int    `json:"channel_id" gorm:"type:bigint unsigned;comment:通道id"`
	TrafficOnId      int    `json:"traffic_on_id" gorm:"type:bigint unsigned;comment:上车点id"`
	MediaId          int    `json:"media_id" gorm:"type:bigint unsigned;comment:媒体处理id"`
	LiveId           string `json:"live_id" gorm:"type:varchar(100);comment:直播间id"`
	PushUrl          string `json:"push_url" gorm:"type:varchar(300);comment:推流地址"`
	RecordTaskId     string `json:"record_task_id" gorm:"type:varchar(100);comment:切换任务id"`
	SwitchTaskId     string `json:"switch_task_id" gorm:"type:varchar(100);comment:切换任务"`
	SwitchOutAddress string `json:"switch_out_address" gorm:"type:varchar(100);comment:切换任务"`
	RecordState      int    `json:"record_state" gorm:"type:tinyint;comment:录制状态 1 录制中 2录制完成 3异常"`
	RecordType       int    `json:"record_type" gorm:"type:tinyint;comment:使用场景 1信源 2调度"`
	models.ModelTime
	models.ControlBy
}

func (SourceRecordTask) TableName() string {
	return "source_record_task"
}

type SourceRecord struct {
	models.Model
	TenantId   string `json:"tenant_id" gorm:"type:varchar(50);comment:租户"`
	SourceId   string `json:"source_id" gorm:"type:bigint;comment:信源id"`
	SourceName string `json:"source_name" gorm:"type:varchar(50);comment:信源名称"`
	FileId     string `json:"file_id" gorm:"type:varchar(100);comment:文件id"`
	LiveId     string `json:"live_id" gorm:"type:varchar(100);comment:直播id"`
	FilePath   string `json:"file_path" gorm:"type:varchar(300);comment:文件路径"`
	StartTime  int64  `json:"start_time" gorm:"type:int;comment:开始时间"`
	EndTime    int64  `json:"end_time" gorm:"type:int;comment:结束时间"`
	Type       string `json:"type" gorm:"type:varchar(20);comment:视频格式"`
	Duration   int    `json:"duration" gorm:"type:int;comment:时长"`
	models.ModelTime
	models.ControlBy
}

func (SourceRecord) TableName() string {
	return "source_record"
}

type AuditHistory struct {
	models.Model
	TenantID       string `json:"tenant_id" gorm:"type:varchar(50);column:tenant_id"`
	SourceID       int    `json:"source_id" gorm:"type:bigint;column:source_id"`
	AssetID        string `json:"asset_id" gorm:"type:varchar(100);column:asset_id"`
	Account        string `json:"account" gorm:"type:varchar(100);column:account"`
	AuditTimeStamp int64  `json:"audit_time_stamp" gorm:"type:int;column:audit_time_stamp"`
	AuditState     int    `json:"audit_state" gorm:"type:tinyint;column:audit_state" comment:"1通过 2不通过 3审核中"`
	models.ModelTime
	models.ControlBy
}

func (AuditHistory) TableName() string {
	return "audit_history"
}

type ChannelTransCodeTask struct {
	models.Model

	TenantId        string `json:"tenant_id" gorm:"type:varchar(50);comment:租户"`
	ChannelId       int    `json:"channel_id" gorm:"type:bigint unsigned;comment:通道id"`
	SourceId        int    `json:"source_id" gorm:"type:bigint unsigned;comment:信源id"`
	TrafficOnId     int    `json:"traffic_on_id" gorm:"type:bigint unsigned;comment:上车点id"`
	TrafficOffId    int    `json:"traffic_off_id" gorm:"type:bigint unsigned;comment:下车点id"`
	MediaId         int    `json:"media_id" gorm:"type:bigint unsigned;comment:媒体处理id"`
	TaskState       int    `json:"task_state" gorm:"type:tinyint;comment:状态1上线2异常 3离线"`
	TransTaskId     string `json:"trans_task_id" gorm:"type:varchar(100);comment:转码任务id"`
	TaskId          string `json:"task_id" gorm:"type:varchar(100);comment:任务id"`
	InNodeId        string `json:"in_node_id" gorm:"type:varchar(100);comment:输入节点id"`
	OutNodeId       string `json:"out_node_id" gorm:"type:varchar(100);comment:输出节点id"`
	LiveId          string `json:"live_id" gorm:"type:varchar(100);comment:全球直播任务id"`
	InUrl           string `json:"in_url" gorm:"type:varchar(300);comment:输入源地址"`
	OutUrl          string `json:"out_url" gorm:"type:varchar(300);comment:输出源地址"`
	PushUrl         string `json:"push_url" gorm:"type:varchar(300);comment:第三方推流地址"`
	ExtraInfo       string `json:"extra_info" gorm:"type:varchar(1000);comment:额外信息"`
	StateUpdateTime int64  `json:"state_update_time" gorm:"column:state_update_time;type:int;comment:节点状态更新时间"`
	OutputStreamId  string `json:"output_stream_id" gorm:"type:varchar(100);comment:下车点输出id"`
	CustomOutUrl    string `json:"custom_out_url" gorm:"type:varchar(100);comment:自定义输出地址"`
	Area            int    `json:"area" gorm:"type:tinyint;comment:1 外网 2内网"`
	models.ModelTime
	models.ControlBy
}

func (ChannelTransCodeTask) TableName() string {
	return "channel_trans_code_task"
}

type ChannelTransTask struct {
	models.Model

	TenantId        string `json:"tenant_id" gorm:"type:varchar(50);comment:租户"`
	ChannelId       int    `json:"channel_id" gorm:"type:bigint unsigned;comment:通道id"`
	SourceId        int    `json:"source_id" gorm:"type:bigint unsigned;comment:信源id"`
	MediaId         string `json:"media_id" gorm:"type:varchar(100);comment:媒体处理id"`
	TaskState       int    `json:"task_state" gorm:"type:tinyint;comment:状态1上线2异常 3离线"`
	TaskId          string `json:"task_id" gorm:"type:varchar(100);comment:任务id"`
	InUrl           string `json:"in_url" gorm:"type:varchar(300);comment:输入地址"`
	OutUrl          string `json:"out_url" gorm:"type:varchar(300);comment:输出地址"`
	Area            int    `json:"area" gorm:"type:tinyint;comment:1 外网 2内网"`
	StateUpdateTime int64  `json:"state_update_time" gorm:"column:state_update_time;type:int;comment:节点状态更新时间"`
	models.ModelTime
	models.ControlBy
}

func (ChannelTransTask) TableName() string {
	return "channel_trans_task"
}
